import System

import Castle.ActiveRecord
import Castle.ActiveRecord.Framework.Config

import net.podhola
import net.podhola.gtd
import net.podhola.gtd.finances

print "Starting..."

CI = System.Globalization.CultureInfo("cs-CZ")
format = CI.DateTimeFormat

expenseEndDateTime = DateTime.ParseExact("1.1.2008", "d.M.yyyy", format)

print expenseEndDateTime.ToString()

source = XmlConfigurationSource("SimpleTesterConfig.xml")

ActiveRecordStarter.Initialize( source, Account, EnteredBill, Expense, Receipt, Balance, PlannedIncome )

print "Started:"

allAccounts = Account.FindAll()

if allAccounts.Length == 0:
	pettycash = Account()
	pettycash.Name = "peněženka"
	pettycash.Save()
else:
	pettycash = allAccounts[ 0 ]

input = Console.ReadLine()

while input != "exit":
	// tady bude rozhodovací kód
	if input == "expenses":
		print "All expenses:" + Expense.FindAll().Length
	elif input == "add":
		expense = Expense()
		expense.Subject = "na chlast a holky"
		//pettycash.Expenses.Add(expense) //<- with default (Inverse=false)
		expense.FromAccount = pettycash // <- with Inverse=true; 
		expense.Amount = 5.0
		expense.SpentOn  = DateTime.Now
		expense.Save()
	elif input == "account":
		print "Expenses on account:" + pettycash.Expenses.Count
	elif input == "bills":
		print "All expenses:" + EnteredBill.FindAll().Length
	input = Console.ReadLine()

	
print "Finished."
